home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 49 / Amiga Format CD49 (2000-01-17)(Future Publishing)(GB)(Track 1 of 3)[!][issue 2000-02].iso / -serious- / misc / football / user / referees.rexx < prev    next >
OS/2 REXX Batch file  |  1999-11-29  |  4KB  |  176 lines

  1. /* Mode=Run */
  2. /* ***********************************************************************
  3.  
  4.    REFEREES PROGRAM FOR FOOTBALL REXX SUITE
  5.   ------------------------------------------
  6.                    Copyright  Mark Naughton 1999
  7.  
  8.  
  9. Version    Date     History
  10. --------------------------------------------------------------------------
  11.  1.0       170699   First release.
  12.            250899   Added error msg to file check.
  13.            280899   Converted to use locale. Some error messages, before
  14.                     reading the locale, will still be in English.
  15.  
  16. **************************************************************************
  17.  
  18. Procedure
  19. ---------
  20.  
  21. 1. Check file exists.
  22. 2. Open '.sflearn' file and read in referees, storing them and if the name
  23.    appears more than once, increment the number of matches played.
  24. 3. Write referees out to temp file and sort.
  25. 4. Display table.
  26. 5. Read temp file and display referees with total matches. Exit.
  27.  
  28. ************************************************************************** */
  29. PARSE ARG league_stuff
  30.  
  31. version      = 1
  32. input_file   = '.sflearn'
  33. refs         = '*RF='
  34. rfnm         = '**'
  35. separator    = '*'
  36. teams.       = '???'
  37. wins.        = '???'
  38. lines.       = '???'
  39. counter      = 0
  40.  
  41.  
  42. league_file = "Data/" || league_stuff
  43.  
  44. if open(datafile,"Data/Football.locale",'r') then do
  45.    line = readln(datafile)
  46.    locdir = strip(line)
  47.    close(datafile)
  48. end
  49. else do
  50.    say
  51.    say "ERROR :    (Referees)"
  52.    say
  53.    say "Cannot read 'Data/Football.locale' for the locale settings."
  54.    exit
  55. end
  56.  
  57. locdir = locdir"User/Referees.data"
  58.  
  59. if open(datafile,"ENV:FootballRXPath",'r') then do
  60.    line = readln(datafile)
  61.    rxdir = strip(line)
  62.    close(datafile)
  63. end
  64. else
  65.    rxdir = "SYS:Rexxc/"
  66.  
  67. if exists(locdir) > 0 then do
  68.   address command rxdir'rx 'locdir
  69.   VarCount = getclip('VarCount')
  70.   do i = 1 to VarCount
  71.     interpret getclip('var.'i)
  72.   end
  73. end
  74. else do
  75.    say
  76.    say "ERROR :    (Referees)"
  77.    say
  78.    say "Cannot find '"locdir"' to read locale settings."
  79.    exit
  80. end
  81.  
  82. if exists(league_file || input_file) = 0  then do
  83.    say
  84.    say rf_error
  85.    say
  86.    say rf_one"'"league_file || input_file"'."
  87.    exit
  88. end
  89.  
  90. if open(datafile,league_file || input_file,'r') then do
  91.    do while ~eof(datafile)
  92.       line = readln(datafile)
  93.       if pos(rfnm,line) > 0 then
  94.          lname = delstr(line,1,3)
  95.       if pos(refs,line) > 0 then do
  96.          name = delstr(line,1,4)
  97.          notin = 0
  98.          do i=1 to counter
  99.             if pos(name,teams.i) > 0 then do
  100.                wins.i = wins.i + 1
  101.                notin = 1
  102.             end
  103.          end
  104.          if notin = 0 then do
  105.             counter = counter + 1
  106.             teams.counter = name
  107.             wins.counter  = 1
  108.          end
  109.       end
  110.    end
  111.    close(datafile)
  112. end
  113. else do
  114.    say
  115.    say rf_error
  116.    say
  117.    say rf_two"'"league_file||input_file"'"rf_three
  118.    exit
  119. end
  120.  
  121. if counter > 1 then do
  122.    if open(datafile,"RAM:Football.tempcup",'w') then do
  123.       do i=1 to counter
  124.          writeln(datafile,left(wins.i,4)"     "teams.i)
  125.       end
  126.       close(datafile)
  127.    end
  128.    else do
  129.       say
  130.       say rf_error
  131.       say
  132.       say rf_four
  133.       exit
  134.    end
  135.    address command 'Exec/Sort4Chars '
  136. end
  137.  
  138.  
  139. say
  140. say center(rf_txt1"'"lname"'",78)
  141. say "-------------------------------------------------------------------------------"
  142. say
  143. say
  144. say rf_txt2
  145. say "-------------------------------------------------------------------------------"
  146. say
  147. i = 0
  148. if counter = 1 then do
  149.    say left(wins.1,4)"     "teams.1
  150.    say
  151. end
  152. else do
  153.    if open(datafile,"RAM:Football.tempcup",'r') then do
  154.       do while ~eof(datafile)
  155.          line = readln(datafile)
  156.          if i = 0 then do
  157.             say upper(line)
  158.             i = 1
  159.          end
  160.          else
  161.             say line
  162.       end
  163.       close(datafile)
  164.    end
  165.    else do
  166.       say
  167.       say rf_error
  168.       say
  169.       say rf_txt3
  170.       exit
  171.    end
  172.    address command 'delete >NIL: RAM:Football.tempcup'
  173. end
  174. say "-------------------------------------------------------------------------------"
  175.  
  176. exit